<!DOCTYPE html>
<html lang="zh-CN">
  <head><meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>


<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">

<meta name="description" content="ARM  环境配置"/><link rel="alternate" href="/default" title="Hexo" ><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=2.11.1" />
<link rel="canonical" href="https://y_kvm.gitee.io/2022/02/21/ARM  环境配置/"/>

<link rel="stylesheet" type="text/css" href="/lib/fancybox/jquery.fancybox.css" /><script type="text/x-mathjax-config">
    MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] } });
  </script>
  <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<link rel="stylesheet" type="text/css" href="/css/style.css?v=2.11.1" />

<script id="baidu_analytics">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?9c3376609b4eb87c460cc9503d43f10e";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script><script src="//cdn1.lncld.net/static/js/3.1.1/av-min.js"></script>
  <script id="leancloud">
    AV.init({
      appId: "mhfJYrvbNrJ7wa3pFNWptaoe-MdYXbMMI",
      appKey: "IDppcTL9Rek0zfezfOeuICaF"
    });
  </script><script>
  window.config = {"leancloud":{"app_id":"mhfJYrvbNrJ7wa3pFNWptaoe-MdYXbMMI","app_key":"IDppcTL9Rek0zfezfOeuICaF"},"toc":true,"fancybox":true,"pjax":"","latex":true};
</script>

    <title>ARM  环境配置 - Hexo</title>
  <meta name="generator" content="Hexo 5.4.1"></head>

  <body><div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/." class="logo">Hexo</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>

<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list"><a href="/">
        <li class="mobile-menu-item">首页
          </li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">标签
          </li>
      </a><a href="/about/">
        <li class="mobile-menu-item">关于
          </li>
      </a></ul>
</nav>
<div class="container" id="mobile-panel">
      <header id="header" class="header"><div class="logo-wrapper">
  <a href="/." class="logo">Hexo</a>
</div>

<nav class="site-navbar"><ul id="menu" class="menu"><li class="menu-item">
          <a class="menu-item-link" href="/">
            首页
            </a>
        </li>
      <li class="menu-item">
          <a class="menu-item-link" href="/tags/">
            标签
            </a>
        </li>
      <li class="menu-item">
          <a class="menu-item-link" href="/about/">
            关于
            </a>
        </li>
      </ul></nav>
</header>

      <main id="main" class="main">
        <div class="content-wrapper">
          <div id="content" class="content"><article class="post">
    <header class="post-header">
      <h1 class="post-title">ARM  环境配置
        </h1>

      <div class="post-meta">
        <span class="post-time">
          2022-02-21
        </span><span class="post-visits"
             data-url="/2022/02/21/ARM%20%20%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/"
             data-title="ARM  环境配置">
          阅读次数 0
        </span>
        </div>
    </header>

    <div class="post-toc" id="post-toc">
    <h2 class="post-toc-title">文章目录</h2>
    <div class="post-toc-content">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%96%E8%AF%91%E5%99%A8-ARM-gcc"><span class="toc-text">编译器 ARM gcc</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85%E7%83%A7%E5%BD%95%E5%B7%A5%E5%85%B7-Openocd"><span class="toc-text">安装烧录工具 Openocd</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8Jlink%E9%A9%B1%E5%8A%A8"><span class="toc-text">使用Jlink驱动</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#VScode"><span class="toc-text">VScode</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%B0%83%E8%AF%95"><span class="toc-text">调试</span></a></li></ol>
    </div>
  </div><div class="post-content"><blockquote>
<p>System: Manjaro</p>
<p>ToolChain: STM32CubeMX + arm-none-eabi-gcc</p>
</blockquote>
<h2 id="编译器-ARM-gcc"><a href="#编译器-ARM-gcc" class="headerlink" title="编译器 ARM gcc"></a>编译器 ARM gcc</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pacman -S arm-none-eabi-gcc arm-none-eabi-binutils arm-none-eabi-newlib arm-none-eabi-gdb </span><br></pre></td></tr></table></figure>

<h2 id="安装烧录工具-Openocd"><a href="#安装烧录工具-Openocd" class="headerlink" title="安装烧录工具 Openocd"></a>安装烧录工具 Openocd</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo pacman -S openocd libusb libtool</span><br></pre></td></tr></table></figure>

<p>添加设备挂载规则</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /usr/share/openocd/contrib </span><br><span class="line">sudo <span class="built_in">cp</span> 60-openocd.rules /etc/udev/rules.d/</span><br></pre></td></tr></table></figure>



<h2 id="使用Jlink驱动"><a href="#使用Jlink驱动" class="headerlink" title="使用Jlink驱动"></a>使用Jlink驱动</h2><blockquote>
<p>由于连接方式采用了SWD默认是JTAG,所以需要添加配置文件</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /usr/share/openocd/scripts/interface/</span><br><span class="line"><span class="comment"># 新建jlink-swd.cfg</span></span><br><span class="line">kate jlink-swd.cfg</span><br></pre></td></tr></table></figure>

<p>jlink-swd.cfg配置内容</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">adapter driver jlink	# jlink驱动</span><br><span class="line">transport select swd 	# 连接模式swd</span><br></pre></td></tr></table></figure>

<h2 id="VScode"><a href="#VScode" class="headerlink" title="VScode"></a>VScode</h2><ol>
<li>安装插件Cortex-Debug</li>
<li>vscode进入项目所在文件夹，在调试处创建launch.json</li>
</ol>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">    <span class="comment">// 使用 IntelliSense 了解相关属性。 </span></span><br><span class="line">    <span class="comment">// 悬停以查看现有属性的描述。</span></span><br><span class="line">    <span class="comment">// 欲了解更多信息，请访问: https://go.microsoft.com/fwlink/?linkid=830387</span></span><br><span class="line">    <span class="attr">&quot;version&quot;</span><span class="punctuation">:</span> <span class="string">&quot;0.2.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;configurations&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">        </span><br><span class="line">    </span><br><span class="line"></span><br><span class="line">        <span class="punctuation">&#123;</span></span><br><span class="line">            <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;Cortex Debug&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;cwd&quot;</span><span class="punctuation">:</span> <span class="string">&quot;$&#123;workspaceRoot&#125;&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;executable&quot;</span><span class="punctuation">:</span> <span class="string">&quot;./build/STM32F103C8_Template.elf&quot;</span><span class="punctuation">,</span> <span class="comment">//修改为自己生成二进制文件名</span></span><br><span class="line">            <span class="attr">&quot;request&quot;</span><span class="punctuation">:</span> <span class="string">&quot;launch&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;type&quot;</span><span class="punctuation">:</span> <span class="string">&quot;cortex-debug&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;servertype&quot;</span><span class="punctuation">:</span> <span class="string">&quot;openocd&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;configFiles&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span><span class="string">&quot;openocd.cfg&quot;</span><span class="punctuation">]</span><span class="punctuation">,</span>			<span class="comment">// 添加openocd配置文件，见3</span></span><br><span class="line">            <span class="attr">&quot;armToolchainPath&quot;</span><span class="punctuation">:</span> <span class="string">&quot;/usr/bin/&quot;</span><span class="punctuation">,</span>		<span class="comment">// arm-none-eabi-gdb存储路径</span></span><br><span class="line">        <span class="punctuation">&#125;</span></span><br><span class="line">    <span class="punctuation">]</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>

<ol start="3">
<li>在项目文件夹下新建openocd文件</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 需要根据jtag工具修改，上文创建的jlink配置文件</span></span><br><span class="line"><span class="built_in">source</span> [find interface/jlink-swd.cfg]			</span><br><span class="line"><span class="comment"># 需要根据要调试的芯片修改</span></span><br><span class="line"><span class="built_in">source</span> [find target/stm32f1x.cfg]</span><br><span class="line"><span class="comment"># use hardware reset, connect under reset</span></span><br><span class="line"><span class="comment"># connect_assert_srst needed if low power mode application running (WFI...)</span></span><br><span class="line"><span class="comment"># reset_config srst_only srst_nogate connect_assert_srst</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="调试"><a href="#调试" class="headerlink" title="调试"></a>调试</h2><p>编译完成后，快捷键f5进行调试</p>

      </div>
      <div class="post-copyright">
    <p class="copyright-item">
      <span>原文作者: </span>
      <a href="https://y_kvm.gitee.io">Explorer</a>
    </p>
    <p class="copyright-item">
      <span>原文链接: </span>
      <a href="https://y_kvm.gitee.io/2022/02/21/ARM%20%20%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/">https://y_kvm.gitee.io/2022/02/21/ARM%20%20%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/</a>
    </p>
    <p class="copyright-item">
      <span>许可协议: </span><a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/" target="_blank">知识共享署名-非商业性使用 4.0 国际许可协议</a>
    </p>
  </div>
      <footer class="post-footer">
        
        <nav class="post-nav"><a class="prev" href="/2022/02/21/Linux%E5%B8%B8%E7%94%A8%E6%8C%87%E4%BB%A4/">
        <i class="iconfont icon-left"></i>
        <span class="prev-text nav-default">Linux常用指令</span>
        <span class="prev-text nav-mobile">上一篇</span>
      </a>
    <a class="next" href="/2022/02/21/Typora%20%E6%90%AD%E9%85%8Dgitee%E5%AE%9E%E7%8E%B0%E4%B8%AA%E4%BA%BA%E5%9B%BE%E5%BA%8A/">
        <span class="next-text nav-default">Typora 搭配gitee实现个人图床</span>
        <span class="prev-text nav-mobile">下一篇</span>
        <i class="iconfont icon-right"></i>
      </a>
    </nav></footer>
    </article></div><div class="comments" id="comments"></div></div>
      </main>

      <footer id="footer" class="footer"><div class="social-links"><a href="mailto:alternatingcurrenttesla@outlook.com" class="iconfont icon-email" title="email"></a>
        <a target="_blank" rel="noopener" href="https://github.com/KVM-Explorer" class="iconfont icon-github" title="github"></a>
        <a href="/atom.xml" class="iconfont icon-rss" title="rss"></a>
    </div><div class="copyright">
  <span class="power-by">
    由 <a class="hexo-link" target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" target="_blank" rel="noopener" href="https://github.com/ahonn/hexo-theme-even">Even</a>
  </span>

  <span class="copyright-year">&copy;2015 - 2022<span class="heart">
      <i class="iconfont icon-heart"></i>
    </span>
    <span class="author">Explorer</span>
  </span>
</div>
</footer>

      <div class="back-to-top" id="back-to-top">
        <i class="iconfont icon-up"></i>
      </div>
    </div><script type="text/javascript" src="/lib/jquery/jquery.min.js"></script>
  <script type="text/javascript" src="/lib/slideout/slideout.js"></script>
  <script type="text/javascript" src="/lib/fancybox/jquery.fancybox.pack.js"></script>
  <script type="text/javascript" src="/js/src/even.js?v=2.11.1"></script>
</body>
</html>
